package 算法;

import java.util.ArrayList;

/**
 * @author coderFu
 * @create 2022/3/17
 */
public class CoderSelected {

    public static void main(String[] args) {
        ArrayList<Integer> list =  new ArrayList<>();
        list.add(2);
        list.add(100);
        list.add(2);
        list.add(3);
        list.add(3);
        list.add(90);
        list.add(3);
        list.add(2);
        list.add(80);
        list.add(2);
        System.out.println(list.get(9));
        int check = check(list);
        System.out.println(check);

    }

    public static int check(ArrayList<Integer> goods){
        int count = 0;
        for(int i=0; i<goods.size(); i++){
            int j = i+1;
            int temp = goods.get(i);
            int compare = goods.get(j);
            if (temp >= compare){
                count = count+compare;
                i++;
            }else{
                count = count +temp;
            }
        }
        return count;



    }
}
